


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
  <title>Coverage Report :: JpaProviderUtils</title>
  <style type="text/css">
    @import "../../.css/coverage.css";
  </style>
</head>

<body>
<div class="header"></div>

<div class="content">
<div class="breadCrumbs">
    [ <a href="../../index.html">all classes</a> ]
    [ <a href="../index.html">at.dormancy.util</a> ]
</div>

<h1>Coverage Summary for Class: JpaProviderUtils (at.dormancy.util)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">JpaProviderUtils</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    55.6%
  </span>
  <span class="absValue">
    (5/ 9)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    66.7%
  </span>
  <span class="absValue">
    (8/ 12)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<div class="sourceCode"><i>1</i>&nbsp;/*
<i>2</i>&nbsp; * Copyright 2013 Gregor Schauer
<i>3</i>&nbsp; *
<i>4</i>&nbsp; * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<i>5</i>&nbsp; * you may not use this file except in compliance with the License.
<i>6</i>&nbsp; * You may obtain a copy of the License at
<i>7</i>&nbsp; *
<i>8</i>&nbsp; *      http://www.apache.org/licenses/LICENSE-2.0
<i>9</i>&nbsp; *
<i>10</i>&nbsp; * Unless required by applicable law or agreed to in writing, software
<i>11</i>&nbsp; * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<i>12</i>&nbsp; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<i>13</i>&nbsp; * See the License for the specific language governing permissions and
<i>14</i>&nbsp; * limitations under the License.
<i>15</i>&nbsp; */
<i>16</i>&nbsp;package at.dormancy.util;
<i>17</i>&nbsp;
<i>18</i>&nbsp;import javax.annotation.Nonnull;
<i>19</i>&nbsp;
<i>20</i>&nbsp;/**
<i>21</i>&nbsp; * Utilities for making JPA providers compatible.
<i>22</i>&nbsp; * &lt;p/&gt;
<i>23</i>&nbsp; * They attempts to load the collection classes regardless of the implementation and version present in the classpath.
<i>24</i>&nbsp; * &lt;p/&gt;
<i>25</i>&nbsp; * Currently, the following JPA providers are supported:
<i>26</i>&nbsp; * &lt;ul&gt;
<i>27</i>&nbsp; *     &lt;li&gt;Hibernate 3&lt;/li&gt;
<i>28</i>&nbsp; *     &lt;li&gt;Hibernate 4&lt;/li&gt;
<i>29</i>&nbsp; *     &lt;li&gt;EclipseLink&lt;/li&gt;
<i>30</i>&nbsp; * &lt;/ul&gt;
<i>31</i>&nbsp; *
<i>32</i>&nbsp; * @author Gregor Schauer
<i>33</i>&nbsp; * @since 2.0.0
<i>34</i>&nbsp; */
<b class="nc"><i>35</i>&nbsp;public class JpaProviderUtils {</b>
<i>36</i>&nbsp;	protected static final String HIBERNATE_3_COLLECTION = &quot;org.hibernate.collection.PersistentCollection&quot;;
<i>37</i>&nbsp;	protected static final String HIBERNATE_3_LIST = &quot;org.hibernate.collection.PersistentList&quot;;
<i>38</i>&nbsp;	protected static final String HIBERNATE_3_SET = &quot;org.hibernate.collection.PersistentSet&quot;;
<i>39</i>&nbsp;	protected static final String HIBERNATE_3_MAP = &quot;org.hibernate.collection.PersistentMap&quot;;
<i>40</i>&nbsp;
<i>41</i>&nbsp;	protected static final String HIBERNATE_4_COLLECTION = &quot;org.hibernate.collection.spi.PersistentCollection&quot;;
<i>42</i>&nbsp;	protected static final String HIBERNATE_4_LIST = &quot;org.hibernate.collection.internal.PersistentList&quot;;
<i>43</i>&nbsp;	protected static final String HIBERNATE_4_SET = &quot;org.hibernate.collection.internal.PersistentSet&quot;;
<i>44</i>&nbsp;	protected static final String HIBERNATE_4_MAP = &quot;org.hibernate.collection.internal.PersistentMap&quot;;
<i>45</i>&nbsp;
<i>46</i>&nbsp;	protected static final String JPA_ECLIPSE_LINK_COLLECTION = &quot;org.eclipse.persistence.indirection.IndirectCollection&quot;;
<i>47</i>&nbsp;	protected static final String JPA_ECLIPSE_LINK_LIST = &quot;org.eclipse.persistence.indirection.IndirectList&quot;;
<i>48</i>&nbsp;	protected static final String JPA_ECLIPSE_LINK_SET = &quot;org.eclipse.persistence.indirection.IndirectSet&quot;;
<i>49</i>&nbsp;	protected static final String JPA_ECLIPSE_LINK_MAP = &quot;org.eclipse.persistence.indirection.IndirectMap&quot;;
<i>50</i>&nbsp;
<b class="fc"><i>51</i>&nbsp;	protected static final Class&lt;?&gt; PERSISTENT_COLLECTION = ClassLookup.find(JPA_ECLIPSE_LINK_COLLECTION, HIBERNATE_4_COLLECTION, HIBERNATE_3_COLLECTION).orThrow(new IllegalStateException(&quot;No supported persistence provider found&quot;)).get();</b>
<b class="fc"><i>52</i>&nbsp;	protected static final Class&lt;?&gt; PERSISTENT_LIST = ClassLookup.find(JPA_ECLIPSE_LINK_LIST, HIBERNATE_4_LIST, HIBERNATE_3_LIST).orThrow(new IllegalStateException(&quot;No supported persistence provider found&quot;)).get();</b>
<b class="fc"><i>53</i>&nbsp;	protected static final Class&lt;?&gt; PERSISTENT_SET = ClassLookup.find(JPA_ECLIPSE_LINK_SET, HIBERNATE_4_SET, HIBERNATE_3_SET).orThrow(new IllegalStateException(&quot;No supported persistence provider found&quot;)).get();</b>
<b class="fc"><i>54</i>&nbsp;	protected static final Class&lt;?&gt; PERSISTENT_MAP = ClassLookup.find(JPA_ECLIPSE_LINK_MAP, HIBERNATE_4_MAP, HIBERNATE_3_MAP).orThrow(new IllegalStateException(&quot;No supported persistence provider found&quot;)).get();</b>
<i>55</i>&nbsp;
<i>56</i>&nbsp;	/**
<i>57</i>&nbsp;	 * Returns {@code true} if Hibernate 3 collections are found in the classpath.
<i>58</i>&nbsp;	 *
<i>59</i>&nbsp;	 * @return {@code true} if Hibernate 3 is available, {@code false} otherwise
<i>60</i>&nbsp;	 */
<i>61</i>&nbsp;	public static boolean isHibernate3() {
<b class="fc"><i>62</i>&nbsp;		return getPersistentCollectionClass().getName().equals(HIBERNATE_3_COLLECTION);</b>
<i>63</i>&nbsp;	}
<i>64</i>&nbsp;
<i>65</i>&nbsp;	/**
<i>66</i>&nbsp;	 * Returns {@code true} if Hibernate 4 collections are found in the classpath.
<i>67</i>&nbsp;	 *
<i>68</i>&nbsp;	 * @return {@code true} if Hibernate 4 is available, {@code false} otherwise
<i>69</i>&nbsp;	 */
<i>70</i>&nbsp;	public static boolean isHibernate4() {
<b class="nc"><i>71</i>&nbsp;		return getPersistentCollectionClass().getName().equals(HIBERNATE_4_COLLECTION);</b>
<i>72</i>&nbsp;	}
<i>73</i>&nbsp;
<i>74</i>&nbsp;	/**
<i>75</i>&nbsp;	 * Returns {@code true} if EclipseLink collections are found in the classpath.
<i>76</i>&nbsp;	 *
<i>77</i>&nbsp;	 * @return {@code true} if EclipseLink is available, {@code false} otherwise
<i>78</i>&nbsp;	 */
<i>79</i>&nbsp;	public static boolean isEclipseLink() {
<b class="fc"><i>80</i>&nbsp;		return getPersistentCollectionClass().getName().equals(JPA_ECLIPSE_LINK_COLLECTION);</b>
<i>81</i>&nbsp;	}
<i>82</i>&nbsp;
<i>83</i>&nbsp;	/**
<i>84</i>&nbsp;	 * Returns the class used by Hibernate for representing a persistent collection.
<i>85</i>&nbsp;	 *
<i>86</i>&nbsp;	 * @return the persistent collection class
<i>87</i>&nbsp;	 */
<i>88</i>&nbsp;	@Nonnull
<i>89</i>&nbsp;	public static Class&lt;?&gt; getPersistentCollectionClass() {
<b class="fc"><i>90</i>&nbsp;		return PERSISTENT_COLLECTION;</b>
<i>91</i>&nbsp;	}
<i>92</i>&nbsp;
<i>93</i>&nbsp;	/**
<i>94</i>&nbsp;	 * Returns the class that represents a persistent list.
<i>95</i>&nbsp;	 *
<i>96</i>&nbsp;	 * @return the persistent list class
<i>97</i>&nbsp;	 */
<i>98</i>&nbsp;	@Nonnull
<i>99</i>&nbsp;	public static Class&lt;?&gt; getPersistentListClass() {
<b class="nc"><i>100</i>&nbsp;		return PERSISTENT_LIST;</b>
<i>101</i>&nbsp;	}
<i>102</i>&nbsp;
<i>103</i>&nbsp;	/**
<i>104</i>&nbsp;	 * Returns the class that represents a persistent set.
<i>105</i>&nbsp;	 *
<i>106</i>&nbsp;	 * @return the persistent set class
<i>107</i>&nbsp;	 */
<i>108</i>&nbsp;	@Nonnull
<i>109</i>&nbsp;	public static Class&lt;?&gt; getPersistentSetClass() {
<b class="fc"><i>110</i>&nbsp;		return PERSISTENT_SET;</b>
<i>111</i>&nbsp;	}
<i>112</i>&nbsp;
<i>113</i>&nbsp;	/**
<i>114</i>&nbsp;	 * Returns the class that represents a persistent map.
<i>115</i>&nbsp;	 *
<i>116</i>&nbsp;	 * @return the persistent map class
<i>117</i>&nbsp;	 */
<i>118</i>&nbsp;	@Nonnull
<i>119</i>&nbsp;	public static Class&lt;?&gt; getPersistentMapClass() {
<b class="nc"><i>120</i>&nbsp;		return PERSISTENT_MAP;</b>
<i>121</i>&nbsp;	}
<i>122</i>&nbsp;}
</div>
</div>

<div class="footer">
    
    <div style="float:right;">generated on 2013-07-31 23:31</div>
</div>
</body>
</html>
